package com.anysoft.me.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

import com.anysoft.linstener.impl.OnNetChangeLinstenerImpl;
import com.anysoft.me.utils.NetWorkUtil;


/**
 * Created by lty on 2017/12/3.
 */

public class NetconnectionStateReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        NetWorkUtil.syncConnectState(context);
        int netWorkType = NetWorkUtil.getNetWorkType(context);
        switch (netWorkType) {
            case 0: //无网络
                if (mLinstener != null)
                    mLinstener.onNetChangeNo();
                break;
            case 1: //wifi
//                break;
            case 2: //2G
//                break;
            case 3: //3G
//                break;
            case 4: //4G
                if (mLinstener != null)
                    mLinstener.onNetChangeHas();
                break;
        }

    }

    public static OnNetChangeLinstenerImpl mLinstener;

    public static void setOnNetChangeLinstener(OnNetChangeLinstenerImpl linstener) {
        mLinstener = linstener;
    }
}
